define(
		[ "PDUtilDir/util", "PDUtilDir/tool", "PDUtilDir/slidebar", "PDUtilDir/inputSelect", "PDUtilDir/fileupload/multiFileUpload" ],
		function(Util, Tool, Slidebar, inputSelect, MFU) {
			function addSupportInit($scope, $compile){
				return new addSupport($scope, $compile);
			};
			function addSupport($scope, $compile){
				this.$scope = $scope;
				this.$compile = $compile;
			};
			addSupport.fn = addSupport.prototype;
			addSupport.fn.init = function(){
				this.entity = {};
			};
			addSupport.fn.digest = function(){
				 this.$scope.$digest();
			};
			addSupport.fn.run = function() {
				var _this = this;
				_this.init();
				this.slidebars = Slidebar({
					size : 'lg',
					url : getServer()
							+ "/static/app/spots/spotsTicket/views/add.html",
					$scope: this.$scope,
					$compile: this.$compile,
					afterLoad : function($Panel) {
						_this.initialization();
					}
				});
			};
			addSupport.fn.initialization = function(){
				this.baseInit();
			};
			addSupport.fn.baseInit = function() {
				var _this = this;
				//加载code
				$.ajax({
					url : getServer()
							+ "/flea/hclv/getUUID.htmls",
					method : 'get',
					success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
						_this.entity.code = data.data;
						_this.digest();
					}
				});
				//类型
				inputSelect.dropCache();
                inputSelect({
                    id:"typeName",
                    key : {
                        id : "dictCode",
                        name : "dictName",
                        data : "data"
                    },
                    data : _this.$scope.cache.typeArray,
                    callback : function(id, data) {
                    	_this.entity.type = id[0];
                    	_this.$scope.addTicketForm.type.$setViewValue(_this.entity.type);
                    }
                });
                //景点列表
				inputSelect.dropCache();
                inputSelect({
                    id: "addSpotName",
                    key : {
                        id : "id",
                        name : "name",
                        data : "data"
                    },
                    data : _this.$scope.cache.spotArray,
                    callback : function(id, data) {
                    	_this.entity.spotId = id[0];
                    	_this.$scope.addTicketForm.spotId.$setViewValue(_this.entity.spotId);
                    }
                });
				
			};
			addSupport.fn.save = function() {
				var _this = this;
				$.ajax({
                    url : getServer() + "/flea/hclv/spotTicket/saveOrUpdateSpotTicket.htmls",
                    data : {
                        "model": JSON.stringify(_this.entity)
                    },
                    success : function(data) {
                        if (data.status != 200) {
                            return;
                        }
                    	_this.$scope.grid.refresh();
                        Util.alert(data.message);
                        _this.slidebars.close();
                    }
				});
			};
			return addSupportInit;
		});